package logic

import (
	"context"
	"user-goods-hub/models/mysql"

	"user-goods-hub/userrpc/internal/svc"
	"user-goods-hub/userrpc/userrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodsListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodsListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsListLogic {
	return &GoodsListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GoodsListLogic) GoodsList(in *userrpc.GoodsListRequest) (*userrpc.GoodsListResponse, error) {
	// todo: add your logic here and delete this line
	var lists []*userrpc.GoodsList
	lists = mysql.GoodsList(mysql.DB, in.UserId)
	return &userrpc.GoodsListResponse{
		List: lists,
	}, nil
}
